package com.csun.cmny.provider.utils;

import com.csun.cmny.mqtt.entity.MsgLog;
import com.csun.cmny.provider.model.dto.log.UploadAppLogRecordDto;
import com.csun.cmny.util.PublicUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Auther: chisj chisj@foxmal.com
 * @Date: 2020-05-19 14:06
 * @Description:
 */
@Slf4j
@Component
public class DeviceLogUtils {

    public void print(MsgLog msgLog) {

        if (PublicUtil.isEmpty(msgLog)) {
            // log为null
            log.warn("=====> device log = upload app log record is null");
        }

        if (PublicUtil.isEmpty(msgLog.getLevel())) {
            log.warn("=====> device log = unknow upload app log record");
            msgLog.setLevel("unknow");
        }

        switch (msgLog.getLevel()) {
            case "debug" :
                log.debug("=====> device device = {}", msgLog.toString());
                break;
            case "info" :
                log.info("=====> device device = {}", msgLog.toString());
                break;
            case "warn" :
                log.warn("=====> device device = {}", msgLog.toString());
                break;
            case "error" :
                log.error("=====> device device = {}", msgLog.toString());
                break;
            case "unknow" :
                log.warn("=====> device device = {}", msgLog.toString());
                break;
        }

    }

}
